<?php defined('SYSPATH') or die('No direct script access.');

class Model_User extends Model_Auth_User {
       
    public function rules()
    {
        return array(
            'username' => array(
                array('not_empty'),
                array('min_length', array(':value', 4)),
                array('max_length', array(':value', 32)),
                array('regex', array(':value', '/^[-\pL\pN_.]++$/uD')),
                array(array($this, 'unique'), array('username', ':value'))
            ),
            'email' => array(
                array('not_empty'),
                array('min_length', array(':value', 4)),
                array('max_length', array(':value', 127)),
                array('email'),
                array(array($this, 'unique'), array('email', ':value')),
            )
        );
    }
        
     public function filters()
    {
        return array(
            'email' => array(
                array('trim'),
            ),
            'username' => array(
                array('trim'),
                array('strip_tags'),
            ),
            'password' => array(
                array(array(Auth::instance(), 'hash')),
            )
        );
    }

}
